package com.neusoft.rental.service.impl;

import com.neusoft.rental.mapper.GoodsMapper;
import com.neusoft.rental.po.Goods;
import com.neusoft.rental.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    //三种功能，一、根据物资名称模糊搜索物资，二、管理员查询所有物资、三、普通用户所有已发放物资
    @Override
    public List<Goods> queryGoodsByName(Goods goods) {
        return goodsMapper.queryGoodsByName(goods);
    }

    //根据物资id搜索物资详情
    @Override
    public Goods queryGoodsById(Integer goodsid) {
        return goodsMapper.queryGoodsById(goodsid);
    }

    //管理员增加新的物资
    @Override
    public int addGoods(Goods goods) {
        return goodsMapper.addGoods(goods);
    }

    //实现了两个功能，一是实现了预约成功或者物质归还成功时物资库存数量的变化，二是管理员修改物资信息
    @Override
    public int updateGoods(Goods goods) {
        return goodsMapper.updateGoods(goods);
    }

    //根据物资id删除物资
    @Override
    public int deleteGoodsById(int goodsid) {
        return goodsMapper.deleteGoodsById(goodsid);
    }

}
